<?php
include('../Config/conn.php');
$r_num = count($redis);
for ($i=1;$i<$r_num+1;$i++){
$redis[$i]->select(1);
$data = $redis[$i]->keys('*');
foreach ($data as $vlues){
    $data1 = $redis[$i]->get($vlues);
    $data = json_decode($data1, true);
    $arr = $data['roles'];
    if ($arr){
    foreach ($arr as $value1){
    $name = $value1['s_name'];
    $roleid = $value1['i_roleid'];
    $lv = $value1['i_lv'];
    $zs = $value1['i_zs'];
    if ($lv =="" or $zs ==""){$lv=0;$zs=0;}
    $sql = "select * from role where roleid=$roleid";
    $result = mysql_query($sql);
    $num = mysql_num_rows($result);
    if ($num == 0 ){
    $sql = "insert into role (roleid,name,lv,zs,account) values ($roleid,'$name',$lv,$zs,'$vlues')";
    $result=mysql_query($sql);
    
    }else{
      $sql = "update role set lv=$lv,zs=$zs where roleid=$roleid";

    $result=mysql_query($sql);
   
  }
    }
        
    }
  
}
}    

?>